home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Updaters / AppMaker 1.5.2->1.5.4 / Libraries / THINK / AMLibraryC / DialogAids.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-19  |  15.9 KB  |  682 lines  |  [TEXT/KAHL]

  1. /* © 1988-91, Bowers Development Corp. */
  2. /* DialogAids.c */
  3.  
  4. #include <Types.h>
  5. #include <Quickdraw.h>
  6. #include <Controls.h>
  7. #include <Desk.h>                /* for SystemTask */
  8. #include <Dialogs.h>
  9. #include <Events.h>
  10. #include <Lists.h>
  11. #include <Menus.h>
  12. #include <TextEdit.h>
  13.  
  14. #include "EventLoop.h"
  15. #include "Globals.h"
  16. #include "ResourceDefs.h"
  17. #include "WindowAids.h"
  18. #include "Windowing.h"
  19. #include "DoScrap.h"
  20.  
  21. #include "DialogAids.h"
  22.  
  23. #include <OSUtils.h>
  24. #include <Packages.h>
  25. #include <ToolUtils.h>
  26. #include "Cursors.h"    /* cursorRgn for WaitNextEvent */
  27.  
  28. #pragma segment DialogAids
  29.  
  30. /*----------*/
  31. Rect    GetDRect    (short        itemNr)
  32. {
  33.     short        itemType;
  34.     Handle        itemHandle;
  35.     Rect        itemRect;
  36.  
  37.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  38.  
  39.     return (itemRect);
  40. } /*GetDRect*/
  41.  
  42. /*----------*/
  43. static Handle    GetItemHandle    (short        itemNr);
  44. static Handle    GetItemHandle    (short        itemNr)
  45. {
  46.     short        itemType;
  47.     Handle        itemHandle;
  48.     Rect        itemRect;
  49.  
  50.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  51.  
  52.     return (itemHandle);
  53. } /*GetItemHandle*/
  54.  
  55. /*----------*/
  56. pascal void LineItem    (DialogPtr        dialog,
  57.                          short            itemNr)
  58. {
  59. #pragma unused (dialog)
  60.  
  61.     PenState        savePen;
  62.     Rect            itemRect;
  63.  
  64.     GetPenState (&savePen);
  65.     PenNormal ();
  66. #ifdef dangerousPattern
  67.     PenPat (qd.gray);
  68. #else
  69.     PenPat (&qd.gray);
  70. #endif
  71.     itemRect = GetDRect (itemNr);
  72.     MoveTo (itemRect.left, itemRect.top);
  73.     LineTo (itemRect.right - 1, itemRect.bottom - 1);
  74.     SetPenState (&savePen);
  75. } /*LineItem*/
  76.  
  77. /*----------*/
  78. pascal void RectItem    (DialogPtr        dialog,
  79.                          short            itemNr)
  80. {
  81. #pragma unused (dialog)
  82.  
  83.     Rect            itemRect;
  84.     PenState        savePen;
  85.  
  86.     GetPenState (&savePen);
  87.     PenNormal ();
  88.     itemRect = GetDRect (itemNr);
  89.     FrameRect (&itemRect);
  90.     SetPenState (&savePen);
  91. } /*RectItem*/
  92.  
  93. /*----------*/
  94. void SetUserItem    (short        itemNr,
  95.                      ProcPtr    doDraw)
  96. {
  97.     short            itemType;
  98.     Handle            itemHandle;
  99.     Rect            itemRect;
  100.  
  101.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  102.     SetDItem (qd.thePort, itemNr, itemType, (Handle) doDraw, &itemRect);
  103. } /*SetUserItem*/
  104.  
  105. /*----------*/
  106. void OutlineButton    (short        itemNr)
  107. {
  108.     Rect            itemRect;
  109.     PenState        savePen;
  110.  
  111.     GetPenState (&savePen);
  112.     PenNormal ();
  113.     PenSize (3, 3);
  114.     itemRect = GetDRect (itemNr);
  115.     InsetRect (&itemRect, -4, -4);
  116.     FrameRoundRect (&itemRect, 16, 16);
  117.     SetPenState (&savePen);
  118. } /*OutlineButton*/
  119.  
  120. /*----------*/
  121. void EnableDItem    (short        itemNr,
  122.                      Boolean    enable)
  123. {
  124.     short            itemType;
  125.     Handle            itemHandle;
  126.     Rect            itemRect;
  127.     ControlHandle    control;
  128.  
  129.     GetDItem (qd.thePort, itemNr, &itemType, &itemHandle, &itemRect);
  130.     if (enable) {
  131.         itemType &= ~itemDisable;
  132.     } else {
  133.         itemType |= itemDisable;
  134.     }
  135.     SetDItem (qd.thePort, itemNr, itemType, itemHandle, &itemRect);
  136.  
  137.     if ((itemType & ctrlItem) != 0) {        /* it's a control */
  138.         control = (ControlHandle) itemHandle;
  139.         HiliteScroll (control, enable);
  140.     } /*else … do nothing?*/
  141. } /*EnableDItem*/
  142.  
  143. /*----------*/
  144. void SetDText        (short        itemNr,
  145.                      Str255        text)
  146. {
  147.     Handle            itemHandle;
  148.  
  149.     itemHandle = GetItemHandle (itemNr);
  150.     SetIText (itemHandle, text);
  151. } /*SetDText*/
  152.  
  153. /*----------*/
  154. void GetDText        (short        itemNr,
  155.                      Str255        text)
  156. {
  157.     Handle            itemHandle;
  158.  
  159.     itemHandle = GetItemHandle (itemNr);
  160.     GetIText (itemHandle, text);
  161. } /*GetDText*/
  162.  
  163. /*----------*/
  164. void SetDNum        (short        itemNr,
  165.                      long        num)
  166. {
  167.     Str255            text;
  168.  
  169.     NumToString (num, text);
  170.     SetDText (itemNr, text);
  171. } /*SetDNum*/
  172.  
  173. /*----------*/
  174. void GetDNum        (short        itemNr,
  175.                      long        *num)
  176. {
  177.     Str255            text;
  178.  
  179.     GetDText (itemNr, text);
  180.     StringToNum (text, num);
  181. } /*GetDNum*/
  182.  
  183. /*----------*/
  184. void SetCheckbox    (short        itemNr,
  185.                      Boolean    checked)
  186. {
  187.     ControlHandle    control;
  188.  
  189.     control = (ControlHandle) GetItemHandle (itemNr);
  190.     SetCtlMax (control, 1);
  191.     SetCtlValue (control, checked);
  192. } /*SetCheckbox*/
  193.  
  194. /*----------*/
  195. void DoCheckbox        (short        itemNr,
  196.                      Boolean    *checked)
  197. {
  198.     *checked = !*checked;
  199.     SetCheckbox (itemNr, *checked);
  200. } /*DoCheckbox*/
  201.  
  202. /*----------*/
  203. void SetRadio        (short        firstItem,
  204.                      short        choice)
  205. {
  206.     SetCheckbox (firstItem + (choice - 1), true); 
  207. } /*SetRadio*/
  208.  
  209. /*----------*/
  210. void DoRadio        (short        firstItem,
  211.                      short        itemNr,
  212.                      short        *choice)
  213. {
  214.     SetCheckbox (firstItem + (*choice - 1), false);
  215.     *choice = itemNr - firstItem + 1;
  216.     SetCheckbox (firstItem + (*choice - 1), true); 
  217. } /*DoRadio*/
  218.  
  219. /*----------*/
  220. static void InvertIcon        (short        itemNr);
  221. static void InvertIcon        (short        itemNr)
  222. {
  223.     Rect            itemRect;
  224.  
  225.     itemRect = GetDRect (itemNr);
  226.     InsetRect (&itemRect, 1, 1);
  227.     InvertRect (&itemRect);
  228. } /*InvertIcon*/
  229.  
  230. /*----------*/
  231. void DoIconRadio    (short        firstIcon,
  232.                      short        itemNr,
  233.                      short        *choice)
  234. {
  235.     InvertIcon (firstIcon + (*choice - 1));
  236.     *choice = (itemNr - firstIcon) + 1;
  237.     InvertIcon (firstIcon + (*choice - 1));
  238. } /*DoIconRadio*/
  239.  
  240. /*----------*/
  241. void SetCtlChoice    (short        itemNr,
  242.                      short        choice)
  243. {
  244.     ControlHandle    control;
  245.  
  246.     control = (ControlHandle) GetItemHandle (itemNr);
  247.     SetCtlValue (control, choice);
  248. } /*SetCtlChoice*/
  249.  
  250. /*----------*/
  251. short GetCtlChoice    (short        itemNr)
  252. {
  253.     ControlHandle    control;
  254.  
  255.     control = (ControlHandle) GetItemHandle (itemNr);
  256.     return (GetCtlValue (control));
  257. } /*GetCtlChoice*/
  258.  
  259. /*----------*/
  260. void DoPalette        (short        itemNr,
  261.                      short        *choice)
  262. {
  263.     *choice = GetCtlChoice (itemNr);
  264. } /*DoPalette*/
  265.  
  266. /*----------*/
  267. void DoMultiState    (short         itemNr,
  268.                      short        *value)
  269. {
  270.     ControlHandle    control;
  271.  
  272.     control = (ControlHandle) GetItemHandle (itemNr);
  273.     if (*value == GetCtlMax (control)) {
  274.         *value = GetCtlMin (control);
  275.     } else {
  276.         *value += 1;
  277.     }
  278.     SetCtlValue (control, *value);
  279. } /*DoMultiState*/
  280.  
  281. /*----------*/
  282. void SetScrollItem  (short        itemNr,
  283.                      short        value,
  284.                      short        min,
  285.                      short        max,
  286.                      short        pageSize)
  287. {
  288.     ControlHandle    scroll;
  289.  
  290.     scroll = (ControlHandle) GetItemHandle (itemNr);
  291.     SetCtlMin     (scroll, min);
  292.     SetCtlMax     (scroll, max);
  293.     SetCtlValue     (scroll, value);
  294.     SetCRefCon     (scroll, pageSize);
  295.     HiliteScroll (scroll, (min < max));
  296. } /*SetScrollItem*/
  297.  
  298. /*----------*/
  299. void DoScrollItem    (short        itemNr,
  300.                      short        *value)
  301. {
  302.     ControlHandle    scroll;
  303.  
  304.     scroll = (ControlHandle) GetItemHandle (itemNr);
  305.     *value = GetCtlValue (scroll);
  306. } /*DoScrollItem*/
  307.  
  308. /*----------*/
  309. void DrawPopup        (short        itemNr,
  310.                      short        menuID,
  311.                      short        choice)
  312. {
  313.     Rect            itemRect;
  314.  
  315.     itemRect = GetDRect (itemNr);
  316.     UpdatePopup (itemRect, menuID, choice);
  317. } /*DrawPopup*/
  318.  
  319. /*----------*/
  320. void DoPopup        (short        itemNr,
  321.                      short        menuID,
  322.                      short        *choice)
  323. {
  324.     Rect            itemRect;
  325.  
  326.     itemRect = GetDRect (itemNr);
  327.     TrackPopup (itemRect, menuID, choice);
  328. } /*DoPopup*/
  329.  
  330. /*----------*/
  331. void InvertLabel    (short        itemNr)
  332. {
  333.     Rect            itemRect;
  334.  
  335.     itemRect = GetDRect (itemNr);
  336.     InvertRect (&itemRect);
  337. } /*InvertLabel*/
  338.  
  339. /*----------*/
  340. ListHandle  Vert1List    (short        itemNr)
  341. {
  342.     Rect            itemRect;
  343.     ListHandle        list;
  344.  
  345.     itemRect = GetDRect (itemNr);
  346.     list = NewV1List (itemRect, qd.thePort);
  347.  
  348.     return (list);
  349. } /*Vert1List*/
  350.  
  351. /*----------*/
  352. Boolean FilterList    (EventRecord    *event,
  353.                      ListHandle        list,
  354.                      short            listItem,
  355.                      short            dblClickItem,
  356.                      short            *itemHit)
  357. {
  358.     Boolean            filtered;
  359.     Point            mousePos;
  360.  
  361.     filtered = false;
  362.     if ((*event).what == mouseDown) {
  363.         mousePos = (*event).where;
  364.         GlobalToLocal (&mousePos);
  365.         if (FindDItem (qd.thePort, mousePos) + 1 == listItem) {
  366.             if (LClick (mousePos, (*event).modifiers, list)) {
  367.                 *itemHit = dblClickItem;
  368.             } else {
  369.                 *itemHit = listItem;
  370.             }
  371.             filtered = true;
  372.         }
  373.     }
  374.     return (filtered);
  375. } /*FilterList*/
  376.  
  377. /*----------*/
  378. Boolean FilterScroll    (EventRecord    *event,
  379.                          short            scrollItem,
  380.                          ScrollProcPtr    actionProc,
  381.                          short            *itemHit)
  382. {
  383.     Boolean            filtered;
  384.     Point            mousePos;
  385.     short            partCode;
  386.     ControlHandle    whichControl;
  387.  
  388.     filtered = false;
  389.     if ((*event).what == mouseDown) {
  390.         mousePos = (*event).where;
  391.         GlobalToLocal (&mousePos);
  392.         if (FindDItem (qd.thePort, mousePos) + 1 == scrollItem) {
  393.             partCode = FindControl (mousePos, qd.thePort, &whichControl);
  394.             if (partCode != 0) {
  395.                 TrackScroll (whichControl, partCode, mousePos, actionProc);
  396.                 *itemHit = scrollItem;
  397.                 filtered = true;
  398.             }
  399.         }
  400.     }
  401.     return (filtered);
  402. } /*FilterScroll*/
  403.  
  404. /*----------*/
  405. void FilterIcon        (EventRecord    *event,
  406.                      short            firstIcon,
  407.                      short            choice)
  408. {
  409.     short            itemType;
  410.     Handle            itemHandle;
  411.     Rect            itemRect;
  412.  
  413.     if (((*event).what == updateEvt)
  414.     &&  ((WindowPtr) (*event).message == qd.thePort)) {
  415.         GetDItem (qd.thePort, firstIcon + (choice - 1), &itemType, &itemHandle, &itemRect);
  416.         PlotIcon (&itemRect, itemHandle);
  417.         ValidRect (&itemRect);
  418.         InsetRect (&itemRect, 1, 1);
  419.         InvertRect (&itemRect);
  420.     }
  421. } /*FilterIcon*/
  422.  
  423. /*----------*/
  424. pascal Boolean StandardFilter    (DialogPtr        whichDialog,
  425.                                  EventRecord    *event,
  426.                                  short            *itemHit)
  427. {
  428.     #define returnKey        13
  429.     #define enter            3
  430.     #define esc                27
  431.     #define pushButton        (ctrlItem + btnCtrl)
  432.     
  433.     Boolean            filtered;
  434.     DialogPeek        whichPeek;
  435.     short            defItem;
  436.     char            key;
  437.     short            itemType;
  438.     Handle            itemHandle;
  439.     Rect            itemRect;
  440.     long            finalTicks;
  441.  
  442.     filtered = false;
  443.     whichPeek = (DialogPeek) whichDialog;
  444.     defItem = whichPeek->aDefItem;
  445.     switch ((*event).what) {
  446.     case keyDown:
  447.     case autoKey:
  448.         key = (*event).message & charCodeMask;
  449.         if ((key == returnKey) || (key == enter) || (key == esc)
  450.         || ((key == '.') && (((*event).modifiers & cmdKey) != 0))) {
  451.             if ((key == returnKey) || (key == enter)) {
  452.                 *itemHit = defItem;
  453.             } else {
  454.                 *itemHit = cancel;
  455.             }
  456.             GetDItem (whichDialog, *itemHit, &itemType, &itemHandle, &itemRect);
  457.             if ((itemType & itemDisable) == 0) {
  458.                 if ((itemType & (255 - itemDisable)) == pushButton) {
  459.                     HiliteControl ((ControlHandle) itemHandle, inButton);
  460.                     Delay (8, &finalTicks);
  461.                     HiliteControl ((ControlHandle) itemHandle, 0);
  462.                 }
  463.                 filtered = true;
  464.             } /*if*/
  465.         } else {
  466.             if ((((*event).modifiers & cmdKey) != 0)
  467.             &&  ((key == 'x') || (key == 'c') || (key == 'v'))) {
  468.                 *itemHit = (whichPeek)->editField + 1;
  469.                 switch (key) {
  470.                 case 'x':
  471.                         DlgCut (whichDialog);
  472.                         scrapDirty = (*itemHit > 0);
  473.                     break;
  474.                 case 'c':
  475.                         DlgCopy (whichDialog);
  476.                         scrapDirty = (*itemHit > 0);
  477.                         *itemHit = 0;
  478.                     break;
  479.                 case 'v':
  480.                         DlgPaste (whichDialog);
  481.                     break;
  482.                 } /*switch*/
  483.                 if (*itemHit > 0) {
  484.                     GetDItem (whichDialog, *itemHit, &itemType, &itemHandle, &itemRect);
  485.                     if ((itemType & itemDisable) == 0) {
  486.                         filtered = true;
  487.                     }
  488.                 }
  489.                 if (!filtered) {
  490.                     (*event).what = nullEvent;
  491.                 }
  492.             }
  493.         }
  494.         break;
  495.     case updateEvt:
  496.         if ((WindowPtr) (*event).message == qd.thePort) {
  497.             GetDItem (whichDialog, defItem, &itemType, &itemHandle, &itemRect);
  498.             if ((itemType & (255 - itemDisable)) == pushButton) {
  499.                 OutlineButton (defItem);
  500.             }
  501.         } else if (!IsDialogEvent (event)) {
  502.             curEvent = *event;
  503.             DoUpdate ();    /* update other windows */
  504.         }
  505.         break;
  506.     } /*switch*/
  507.     return (filtered);
  508. } /*StandardFilter*/
  509.  
  510. /*----------*/
  511. /* This procedure is called by DoModalEvent to handle a mouseDown in a */
  512. /* movable modal dialog. */
  513. /*----------*/
  514. static void    DoMouseDown (void);
  515. static void    DoMouseDown (void)
  516. {
  517.     long            menuChoice;
  518.     short            menuID;
  519.     short            itemNr;
  520.     WindowPtr        whichWindow;
  521.     short            whichPart;
  522.  
  523.     whichPart = FindWindow (curEvent.where, &whichWindow);
  524.     switch (whichPart) {
  525.         case inMenuBar:
  526.                 menuChoice = MenuSelect (curEvent.where);
  527.                 menuID = HiWord (menuChoice);
  528.                 itemNr = LoWord (menuChoice);
  529.                 if ((menuID != 0) && (itemNr != 0)) {
  530. /*Need to handle Cut, Copy, Paste here just like StandardFilter does.*/
  531.                     SysBeep (1);
  532.                 }    /* otherwise, MenuSelect returned 0. Either the user    */
  533.                     /* chose nothing, or the user chose from a System        */
  534.                     /* menu, and it's been taken care of                    */
  535.             break;
  536.         case inDrag:
  537.                 if (whichWindow == FrontWindow ()) {
  538.                     DoDrag (whichWindow);            /*permit drag of this dialog*/
  539.                 } else {
  540.                     SysBeep (1);                    /*can't drag any other window*/
  541.                 }
  542.             break;
  543.         case inSysWindow:
  544.         case inContent:
  545.         case inDesk:
  546.         case inGrow:
  547.         case inGoAway:
  548.         case inZoomIn:
  549.         case inZoomOut:
  550.         default:
  551.                 SysBeep (1);
  552.             break;
  553.     } /*case*/
  554. } /*DoMouseDown*/
  555.  
  556. /*----------*/
  557. static Boolean        sFiltered;            /*used by DoModalEvent & MovableDialog*/
  558.  
  559. /*----------*/
  560. static Boolean GetEvent    (void);
  561. static Boolean GetEvent    ()
  562. {
  563.     Boolean            gotEvent;
  564.  
  565.     if (sysConfig.hasWNE) {
  566.         gotEvent = WaitNextEvent (everyEvent, &curEvent, 0L, cursorRgn);
  567.     } else {
  568.         SystemTask ();
  569.         gotEvent = GetNextEvent (everyEvent, &curEvent);
  570.     }
  571.     return (gotEvent);
  572. } /*GetEvent*/
  573.  
  574. /*----------*/
  575. /* This function processes the next modal dialog event and then returns. It is called        */
  576. /* by MovableDialog, but it can also be called directly. Assumes that the frontmost            */
  577. /* window is a modal (or movable modal) dialog window.                                        */
  578. /*                                                                                            */
  579. /* If the event is associated with an item in the current dialog, returns the item number.    */
  580. /* If filterProc (or System 7.0's standard filter, or DialogSelect) handled the event        */
  581. /* (and presumably set itemHit); sets sFiltered to true, otherwise sets sFiltered to false.    */
  582. /* If the event is not associated with an item in the current dialog, returns 0.            */
  583. /*----------*/
  584. short    DoModalEvent    (ModalFilterProcPtr        filterProc)
  585. {
  586.     WindowPtr        eventWindow;
  587.     short            itemHit;        /*function return value*/
  588.     GrafPtr            savePort;
  589.     DialogPtr        theDialog;
  590.  
  591.     GetPort(&savePort);
  592.  
  593.     sFiltered = false;
  594.     itemHit = 0;
  595.     theDialog = FrontWindow ();
  596.     if (GetEvent () || (curEvent.what == nullEvent)) {
  597.                                 /*got an event to process*/
  598.         if (curEvent.what == app4Evt) {
  599.           /* here so event won't get swallowed by IsDialogEvent */
  600.           /* and so suspend/resume can be translated to deactivate/activate */
  601.             DoApp4Event ();
  602.         }
  603.         if (IsDialogEvent (&curEvent)) {
  604.                                     /*it's a dialog event*/
  605.             if ((curEvent.what == activateEvt) || (curEvent.what == updateEvt)) {
  606.                 eventWindow = (DialogPtr) curEvent.message;
  607.             } else {
  608.                 eventWindow = FrontWindow ();
  609.             }
  610.             SetPort (eventWindow);
  611.             if (filterProc != NULL) {
  612.                                 /*caller passed a filterProc*/
  613.                 sFiltered = (*filterProc) (theDialog, &curEvent, &itemHit);
  614.             } else {
  615.                                 /*filterProc == NULL*/
  616. /* Need to do if (gestalt then if gestalt(stdfilter available)) sFiltered = stdfilter ()    */
  617. /* See Tech Note #304 p. 4 for GetStdFilterProc                                                */
  618.                 sFiltered = StandardFilter (theDialog, &curEvent, &itemHit);
  619.             }
  620.             if (!sFiltered) {
  621.                     /*either filterProc == NULL, or filterProc
  622.                      didn't process curEvent (although filterProc
  623.                      may have altered curEvent)*/
  624. /*Don't need to handle Cmd-keys here, since StandardFilter does.*/
  625.                 sFiltered = DialogSelect (&curEvent, &theDialog, &itemHit);
  626.             } /*otherwise, sFiltered*/
  627.         } else {                /*it's not a dialog event*/
  628.             switch (curEvent.what) {
  629.                 case mouseDown:
  630.                         DoMouseDown ();
  631.                     break;
  632.                 case mouseUp:
  633.                 case keyDown:
  634.                 case autoKey:
  635.                                     /*do nothing*/
  636.                     break;
  637.                 case updateEvt:
  638.                         DoUpdate ();
  639.                     break;
  640.                 case activateEvt:
  641.                                     /*do nothing, to avoid setting cur to noCur*/
  642.                     break;
  643.                 case diskEvt:
  644.                         DoDiskEvent ();
  645.                     break;
  646.                 default:
  647.                         /*Do nothing*/
  648.                     break;
  649.             } /*case*/
  650.         } /*if dialog event or not*/
  651.     } /*otherwise, not GetEvent and curEvent.what != nullEvent*/
  652.  
  653.     SetPort(savePort);
  654.  
  655.     return (itemHit);
  656. } /*DoModalEvent*/
  657.  
  658. /*----------*/
  659. /* This procedure works just like ModalDialog, case plus:                            */
  660. /*    - clicking and dragging in the dialog's title bar will move the dialog            */
  661. /*    - application windows update                                                    */
  662. /*    - under System 7.0, uses the same standard filter proc as ModalDialog            */
  663. /* Under System 7.0, the dialog window's procID should be movableDBoxProc            */
  664. /* (== 5, from Windows.p).                                                            */
  665. /* Under System 6.x, procID movableDBoxProc is equivalent to dBoxProc, and the        */
  666. /* user won't be able to drag the dialog. However, if the procID is noGrowDocProc,    */
  667. /* then the user will be able to drag the dialog.                                    */
  668. /* Modifies global curEvent (Globals.p).                                            */
  669. /*----------*/
  670. void    MovableDialog    (ModalFilterProcPtr        filterProc,
  671.                          short                    *itemHit)
  672. {
  673. /*Need to disable all of application's menus except Cut/Copy/Paste here*/
  674.     *itemHit = 0;
  675.     if (FrontWindow () != NULL) {
  676.         sFiltered = false;
  677.         while (!sFiltered) {
  678.             *itemHit = DoModalEvent (filterProc);        /*also sets sFiltered*/
  679.         } /*while not sFiltered*/
  680.     } /*otherwise, no front window*/
  681. } /*MovableDialog*/
  682.